package com.manger.thread;

import com.alibaba.fastjson.JSONObject;
import com.manger.chrome.DriverManger;
import com.manger.common.office.sax.ExcelFactory;
import com.manger.common.office.sax.parse.SAXSheetRowHandler;
import com.manger.model.CaseInfo;
import com.manger.utils.*;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.xml.sax.InputSource;

import javax.swing.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilterOutputStream;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.util.*;
import java.util.stream.Collectors;

public class AutoCaseThread extends Thread {


    private String autoCaseDirPath;

    private boolean close = false;

    public AutoCaseThread(String autoCaseDirPath) {
        this.autoCaseDirPath = autoCaseDirPath;
    }

    @Override
    public void run() {
        HeartBeatThread hbt = new HeartBeatThread();
        try {

            //读取数据文件
            String excelFilePath = autoCaseDirPath + "/" + SystemConstant.CASE_FILE_EXCEL_NAME;
            File file = new File(excelFilePath);
            if (!file.exists()) {
                System.out.println("没有找到要素表！【" + excelFilePath + "】");
                return;
            }
            Map<String, List<?>> map = ExcelFactory.getExcelFactory().getParseExecutor().parse(file, CaseInfo.class).listen(new SAXSheetRowHandler<CaseInfo>() {
                @Override
                public CaseInfo row(String sheetName, CaseInfo caseInfo, int rowNum) {
                    return caseInfo;
                }
            }).get();
            if (map.keySet().size() == 0) {
                System.out.println("没有解析到要素表!");
                return;
            }
            List<CaseInfo> caseInfoList = (List<CaseInfo>) map.get(map.keySet().iterator().next());
            if (caseInfoList == null || caseInfoList.size() == 0) {
                System.out.println("要素表数为空！");
                return;
            }

            if(DataTools.hasUseProxy){
                String url = DataTools.baseUrl + "/proxy/getCanUseProxyIp?loginUserId=" + DataTools.loginUserId;
                JSONObject jsonObject = RemoteExecute.execute(url);
                if(StringUtils.isEmpty(jsonObject.getString("ip"))){
                    JOptionPane.showMessageDialog(null, "没有获取的代理Ip，请联系管理员!", "警告", JOptionPane.WARNING_MESSAGE);
                    return;
                }

                DataTools.useProxyId = jsonObject.getString("id");

                hbt.start();

                DriverManger.init(jsonObject.getString("ip"),
                        jsonObject.getIntValue("port"));

            }else {
                DriverManger.init();
            }


           /* WebElement loginContent = DriverManger.driver.findElement(By.className("fd-input-loginid")).findElement(By.tagName("input"));
            WebElement password = DriverManger.driver.findElement(By.className("fd-input-pwd")).findElement(By.tagName("input"));

            //
             loginContent.sendKeys("15928074860"); //杨树
            password.sendKeys("JJH1996616as");*/
            /*  loginContent.sendKeys("13618598963");
            password.sendKeys("LZQ13618598963");*/

            /*loginContent.sendKeys("13708210462"); 中信
            password.sendKeys("xpy13708210462");*/

           /* loginContent.sendKeys("15285761207"); //极融
            password.sendKeys("lyq15285761207");*/

            /*loginContent.sendKeys("19160784989");
            password.sendKeys("Aa224108");*/

            WebDriverWait wait = new WebDriverWait(DriverManger.driver, Duration.ofSeconds(500000));
            WebElement result = wait.until(ExpectedConditions.presenceOfElementLocated(By.className("fd-case-space-btn")));
            WebElement zxlaElement = DriverManger.driver.findElement(By.className("fd-menu-zxla"));
            zxlaElement.click();
            System.out.println("===================自动立案====================");
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
            String executeLogExcel = autoCaseDirPath + "/" + "执行记录_" + sdf.format(new Date()) + ".xlsx";
            File file1 = new File(executeLogExcel);
            file1.createNewFile();
            int index = -1;
            try {
                DriverManger.driver.get("https://zxfw.court.gov.cn/zxfw/#/pagesWsla/pc/list/index");
                DriverUtils.wait(2);
                while (index < caseInfoList.size() - 1) {
                    index ++;
                    CaseInfo caseInfo = caseInfoList.get(index);
                    try {
                        caseInfo.setReason("");
                        caseInfo.setExecuteState("");
                        //被告是否是公司【企业贷】
                        boolean isDefendantCompanyCase = StringUtils.isEmpty(caseInfo.getDefendantLegalRepresentativeName()) ? false : true;

                        String caseFilesDir = autoCaseDirPath + "/" + SystemConstant.CASE_FILE_DIR_NAME
                                + "/" + caseInfo.getDefendantName() + "-" + caseInfo.getDefendantIDCard();

                        if (isDefendantCompanyCase) {
                            caseFilesDir = autoCaseDirPath + "/" + SystemConstant.CASE_FILE_DIR_NAME + "/" + caseInfo.getDefendantLegalRepresentativeName();
                            System.out.println("正在处理数据： 【" + (caseInfoList.size() - index) + "】" +  caseInfo.getDefendantLegalRepresentativeName());
                        }else {
                            System.out.println("正在处理数据：" + "【" + (caseInfoList.size() - index) + "】" + caseInfo.getDefendantName() + "-" + caseInfo.getDefendantIDCard());
                        }

                        File fileDir = new File(caseFilesDir);
                        if (!fileDir.exists()) {
                            caseInfo.setExecuteState("失败");
                            caseInfo.setReason("没有找到材料数据!");
                            saveExecuteLogs(executeLogExcel,caseInfoList);
                            if (isDefendantCompanyCase) {
                                System.out.println("没有找到材料数据跳过!【" + caseInfo.getDefendantLegalRepresentativeName() + "】");
                            }else {
                                System.out.println("没有找到材料数据跳过!【" + caseInfo.getDefendantName() + "-" + caseInfo.getDefendantIDCard() + "】");
                            }
                            continue;
                        }

                        if (checkAutoCaseExist(caseInfo,isDefendantCompanyCase)) {
                            caseInfo.setExecuteState("成功");
                            caseInfo.setReason("已经立案，跳过!");
                            saveExecuteLogs(executeLogExcel,caseInfoList);
                            System.out.println("已经立案，跳过!");
                            continue;
                        }
                        DriverManger.driver.get("https://zxfw.court.gov.cn/zxfw/#/pagesWsla/pc/zxla/pick-case-type/index");
                        caseFilling(caseFilesDir, caseInfo, isDefendantCompanyCase);
                        DriverManger.driver.get("https://zxfw.court.gov.cn/zxfw/#/pagesWsla/pc/zxla/pick-case-type/index");
                        DriverUtils.wait(2);//等5秒进行下一个
                        caseInfo.setExecuteState("成功");
                        saveExecuteLogs(executeLogExcel,caseInfoList);
                    } catch (Throwable e) {
                       try{
                           e.printStackTrace();
                           System.out.println("没有等到指定标签，执行失败！");
                           caseInfo.setExecuteState("失败");
                           caseInfo.setReason(e.getMessage());
                           saveExecuteLogs(executeLogExcel,caseInfoList);
                           DriverManger.driver.get("https://zxfw.court.gov.cn/zxfw/#/pagesWsla/pc/zxla/pick-case-type/index");
                           DriverUtils.wait(2);
                       }catch (Exception ex){
                           ex.printStackTrace();
                       }
                    }
                }
            } catch (Throwable ex) {
                System.out.println("执行异常，请关闭程序整理要素表后在试！");
                ex.printStackTrace();
            }
            System.out.println("执行结束！");
        } catch (Throwable e) {
            System.out.println("执行异常，请关闭程序整理要素表后在试！");
            e.printStackTrace();
        } finally {
            if(DriverManger.driver != null){
                DriverManger.driver.quit();
            }
            hbt.interrupt();//关闭心跳
        }
    }

    private void saveExecuteLogs(String executeLogExcel,List<CaseInfo> caseInfoList) throws Exception {
        ExcelFactory.getExcelFactory().getExportExecutor().sheet("执行记录")
                .head(CaseInfo.class).data(caseInfoList).write(new FileOutputStream(executeLogExcel));
    }

    public boolean checkAutoCaseExist(CaseInfo caseInfo,boolean isDefendantCompanyCase) throws Exception {
        DriverUtils.wait(2);
        WebElement element = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-left-window/div/uni-view/uni-view/uni-view[4]/uni-view[2]"));
        element.click();
        DriverUtils.wait(3);

        WebElement showInput = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view/uni-view[2]/uni-view[1]/uni-view"));
        showInput.click();
        DriverUtils.wait(1);

        WebElement input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-input/div/form/input"));
        input.sendKeys( isDefendantCompanyCase ? caseInfo.getDefendantLegalRepresentativeName() : caseInfo.getDefendantName());

        DriverUtils.wait(1);

        WebElement button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view/uni-view[2]/uni-text"));
        button.click();
        DriverUtils.wait(3);
        while (true){
            try{
                WebElement loading =  DriverManger.driver.findElement(By.className("uni-loading"));
                DriverUtils.wait(1);
                continue;
            }catch (Exception e){
                System.out.println("查询结束");
                break;
            }
        }

        List<String> allWindowHandleList = new ArrayList<>();
        try {
            List<WebElement> caseItemElementList = DriverManger.driver.findElements(By.className("fd-case-item"));
            if (caseItemElementList.size() <= 0) {
                return false;
            }
            if(!isDefendantCompanyCase){
                return checkNoDefendantCompany(caseInfo,caseItemElementList,allWindowHandleList);
            }
            return checkDefendantCompany(caseInfo,caseItemElementList);
        }finally {
            Set<String> tempSet = DriverManger.driver.getWindowHandles();
            allWindowHandleList = DriverManger.driver.getWindowHandles().stream().collect(Collectors.toList());
            if(allWindowHandleList != null && allWindowHandleList.size() > 1) {
                for(String handle: allWindowHandleList){
                    System.out.println(handle);
                    DriverManger.driver.switchTo().window(handle);
                    if(!"案件空间".equals(DriverManger.driver.getTitle())){
                        continue;
                    }
                    DriverManger.driver.close();
                }
                DriverManger.driver.switchTo().window(allWindowHandleList.get(0));
            }
        }
    }

    public boolean checkDefendantCompany(CaseInfo caseInfo,List<WebElement> caseItemElementList){
        for (WebElement caseItemElement : caseItemElementList) {
            String state = caseItemElement.findElement(By.className("fd-header-status")).getText();
            String title = caseItemElement.findElement(By.className("fd-header-ajmc")).getText();
            title = title.replaceAll(" ", "");
            if (title.contains(caseInfo.getUnitName().replaceAll(" ", "")) && !"待提交".equals(state)) {
                System.out.println(state + " " + title );
                return true;
            }
        }
        return false;
    }

    // 被告不是公司
    public boolean checkNoDefendantCompany(CaseInfo caseInfo,List<WebElement> caseItemElementList,List<String> allWindowHandleList) throws Exception{
        for (WebElement caseItemElement : caseItemElementList) {
            String state = caseItemElement.findElement(By.className("fd-header-status")).getText();
            String title = caseItemElement.findElement(By.className("fd-header-ajmc")).getText();
            title = title.replaceAll(" ", "");
            if (title.contains(caseInfo.getUnitName().replaceAll(" ", "")) && !"待提交".equals(state)) {
                System.out.println(state + " " + title);
                DriverUtils.wait(1);
                //同姓，同法院，同原告问题
                WebElement caseSpaceElement = caseItemElement.findElement(By.className("fd-case-space-btn"));
                caseSpaceElement.click();
                DriverUtils.wait(2);
                allWindowHandleList = DriverManger.driver.getWindowHandles().stream().collect(Collectors.toList());
                if(allWindowHandleList != null && allWindowHandleList.size() <= 1) {
                    throw new Exception("打开案件空间失败！");
                }
                DriverManger.driver.switchTo().window(allWindowHandleList.get(allWindowHandleList.size() - 1));
                DriverUtils.wait(2);
                try {
                    System.out.println("开始：等待页面加载完成!");
                    DriverUtils.getWaitElement(DriverManger.driver,30,By.className("uni-forms-item__content"));
                    System.out.println("结束：等待页面加载完成!");
                }catch (Exception e){
                    System.out.println("等待案件空间页面超时！");
                    throw new Exception("等待案件空间页面超时!");
                }
                try{
                    List<WebElement> temp =  DriverManger.driver.findElement(By.className("fd-com-main-container"))
                            .findElements(By.className("uni-section"));
                    for(WebElement temp2 : temp){
                        String titleName = temp2.findElement(By.className("uni-section-header__content")).getText();
                        if(titleName.contains("被告")){
                           List<WebElement> itemList =  temp2.findElements(By.className("uni-forms-item"));
                            String idCard = itemList.get(4).findElement(By.className("uni-forms-item__content")).getText();;
                            System.out.println(idCard + "  " + caseInfo.getDefendantIDCard());
                            if (idCard.equals(caseInfo.getDefendantIDCard())) {
                                DriverManger.driver.close();
                                allWindowHandleList = DriverManger.driver.getWindowHandles().stream().collect(Collectors.toList());
                                DriverManger.driver.switchTo().window(allWindowHandleList.get(0));
                                return true;
                            }
                            break;
                        }
                    }
                }catch (Exception e){
                    e.printStackTrace();
                    System.out.println("获取被告身份证信息超时！");
                    throw new Exception("获取被告身份证信息超时!");
                }

                DriverManger.driver.close();
                allWindowHandleList = DriverManger.driver.getWindowHandles().stream().collect(Collectors.toList());
                DriverManger.driver.switchTo().window(allWindowHandleList.get(0));
            }
        }
        return false;
    }

    private void caseFilling(String caseFilesDir, CaseInfo caseInfo, boolean isDefendantCompanyCase) throws Exception {

        WebElement autoCaseBtn = DriverUtils.getWaitElement(DriverManger.driver, By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[1]/uni-view[2]/uni-view[3]/uni-view[2]/uni-view[1]"));
        autoCaseBtn.click();

        DriverManger.driver.close();

        List<String> allWindowHandleList = DriverManger.driver.getWindowHandles().stream().collect(Collectors.toList());
        DriverManger.driver.switchTo().window(allWindowHandleList.get(allWindowHandleList.size() - 1));

        WebElement province = DriverUtils.getWaitElement(DriverManger.driver, By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-view/uni-view"));

        province.click();

        DriverUtils.randomWait();
        boolean flag = false;
        List<WebElement> selectItems = province.findElements(By.className("uni-select__selector-item"));

        for (WebElement selectItem : selectItems) {
            try {
                if (selectItem == null) {
                    continue;
                }
                String text = selectItem.getText();
                if (text.contains(caseInfo.getDefendantProvince())) {
                    selectItem.click();
                    flag = true;
                }
            } catch (Exception e) {

            }
        }

        if(!flag){
            throw new Exception("没有找到被告省信息！");
        }


        WebElement searchBtn = DriverUtils.getWaitElement(DriverManger.driver, By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[2]/uni-button"));
        searchBtn.click();

        DriverUtils.wait(3);
        //获取法院父节点
        WebElement courtNameParent = DriverUtils.getWaitElement(DriverManger.driver, By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[3]/uni-view[3]/uni-view/uni-radio-group"));

        flag = false;

        //法院
        List<WebElement> courtNameList = courtNameParent.findElements(By.className("uni-label-pointer"));
        for (WebElement courtName : courtNameList) {
            try {
                String text = courtName.getText().trim();
                if (text.contains(caseInfo.getCourtName()) ||
                        (StringUtils.isNotEmpty(caseInfo.getCourtName()) && caseInfo.getCourtName().contains(text))) {
                    courtName.click();
                    flag = true;
                    break;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        DriverUtils.wait(1);

        if(!flag){
            throw new Exception("没有找到法院信息！");
        }
        //关闭弹出
        WebElement dialog = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[5]/uni-view/uni-view/uni-view[2]/uni-view/uni-view[2]/uni-view/uni-view/uni-button[2]"));
        if (dialog != null) {
            dialog.click();
        }

        DriverUtils.wait(1);

        //申请类型
        WebElement applyTypeBtn = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[3]/uni-view[5]/uni-view/uni-radio-group/uni-label[2]"));

        applyTypeBtn.click();

        WebElement nextPageBtn = DriverUtils.getWaitElement(DriverManger.driver, By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[4]/uni-button"));
        nextPageBtn.click();
        DriverUtils.wait(2);

        WebElement iKnow = DriverUtils.getWaitElement(DriverManger.driver, By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[8]/uni-checkbox-group/uni-label/uni-checkbox"));
        iKnow.click();

        DriverUtils.wait(2);


        nextPageBtn = DriverUtils.getWaitElement(DriverManger.driver, By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-button[2]"));
        nextPageBtn.click();

        DriverUtils.wait(2);
        try {
            dialog = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[3]/uni-view/uni-view[2]/uni-view/uni-view[2]/uni-view/uni-view[2]/uni-button[2]"));
            dialog.click();
        } catch (Exception e) {
            System.out.println("弹出框没有弹出!");
        }

        DriverUtils.wait(1);

        dialog = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[3]/uni-view/uni-view[2]/uni-view/uni-view[2]/uni-view/uni-view[2]/uni-button[2]"));
        dialog.click();

        DriverUtils.wait(2);
        WebElement chooseAutoCaseType = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view/uni-view/uni-view/uni-view[2]/uni-view[2]"));
        chooseAutoCaseType.click();

        DriverUtils.wait(3);
        WebElement caseTypeInput = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[2]/uni-view[1]"));
        caseTypeInput.click();
        WebElement searchInput = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[2]/uni-view[3]/uni-view[3]/uni-input/div/input"));
        searchInput.sendKeys(caseInfo.getRegisterType());

        DriverUtils.wait(2);
        WebElement searchResult = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[2]/uni-view[3]/uni-view[4]/uni-view/uni-scroll-view/div/div/div/uni-view/uni-text"));
        searchResult.click();

        DriverUtils.wait(1);

        nextPageBtn = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[3]/uni-button"));

        nextPageBtn.click();

        DriverUtils.wait(2);

        WebElement temp = DriverUtils.getWaitElement(DriverManger.driver, By.className("uni-section"));
        DriverUtils.wait(2);

        List<WebElement> uploadBtnList = DriverManger.driver.findElements(By.className("fd-com-upload-grid-container"));

        //起诉状  fd-file-name
        DriverUtils.uploadDir(uploadBtnList.get(0), caseFilesDir + "/" + LoanFileEnum.INDICTMENT.getName(),"起诉状-");
        DriverUtils.wait(2);

        //当事人
        DriverUtils.uploadDir(uploadBtnList.get(1), caseFilesDir + "/" + LoanFileEnum.PART_IDENTITY_CERTIFICATE.getName(),"当事人身份证明-");
        DriverUtils.wait(2);
        //委托
        DriverUtils.uploadDir(uploadBtnList.get(2), caseFilesDir + "/" + LoanFileEnum.ENTRUSTMENT_INFORMATION.getName(),"委托代理人委托手续和身份材料-");
        DriverUtils.wait(2);

        //证据目录
        DriverUtils.uploadDir(uploadBtnList.get(3), caseFilesDir + "/" + LoanFileEnum.EVIDENCE_MATERIALS.getName(),"证据目录及证据材料-");
        DriverUtils.wait(2);

        //送达地址确认书
        DriverUtils.uploadDir(uploadBtnList.get(4), caseFilesDir + "/" + LoanFileEnum.CONFIRMATION_DELIVERY_ADDRESS.getName(),"送达地址确认书-");
        DriverUtils.wait(2);

        nextPageBtn = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[3]/uni-button[2]"));
        int num = 150;
        while (true){
            try {
                num -- ;
                if(num <= 0){
                    break;
                }
                String attrValue = nextPageBtn.getAttribute("disabled");
                System.out.println("attrValue: "  + attrValue);
                if(attrValue.equals("true")){
                    System.out.println("上传没有完成，请等待！");
                    Thread.sleep(1000);
                    continue;
                }
            }catch (Exception e){
                System.out.println("上传结束！");
            }
            break;
        }

        if(num <= 0){
            throw new Exception("没有等到上传结束标识，请稍后在试！");
        }

        DriverUtils.wait(3);
        nextPageBtn.click();

        boolean mark = true;
        //完善案件信息，等等金额框加载完成
        WebElement caseMoneyInput;
        try {
            caseMoneyInput = DriverUtils.getWaitElement(DriverManger.driver, By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view/uni-view/uni-form/span/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
            caseMoneyInput.sendKeys(caseInfo.getCaseMoney());
            mark = true;
        } catch (Exception e) {
            mark = false;
            System.out.println("页面没有加载出AI识别结果，重新获取标的金额输入框");
            caseMoneyInput = DriverUtils.getWaitElement(DriverManger.driver, By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[1]/uni-view[2]/uni-view/uni-view/uni-form/span/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
            caseMoneyInput.sendKeys(caseInfo.getCaseMoney());
        }

        if (mark) {
            System.out.println("识别出数据！");
            hasAiContentHandle(caseInfo, isDefendantCompanyCase);
        } else {
            System.out.println("没有识别出数据！");
            noHasAiContentHandle(caseInfo, isDefendantCompanyCase);
        }

        WebElement submitBtn = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-button[2]"));
        submitBtn.click();
        DriverUtils.wait(2);

        submitBtn = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[3]/uni-view/uni-view[2]/uni-view/uni-view[2]/uni-view/uni-view[3]/uni-button[1]"));
        submitBtn.click();
        DriverUtils.wait(2);

    }

    public void noHasAiContentHandle(CaseInfo caseInfo, boolean isDefendantCompanyCase) {
        //添加法人
        WebElement button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[1]/uni-view[3]/uni-view/uni-view[3]"));
        button.click();
        DriverUtils.wait(2);

        //名称
        WebElement input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getUnitName());

        //住所地（主要办事机构所在地）
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[3]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getPlaintiffAddress());
        DriverUtils.wait(1);

        //国别或地区
        WebElement countryChoose = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[4]/uni-view[2]/uni-view[1]/uni-view"));
        countryChoose.click();
        DriverUtils.wait(1);

        WebElement chinaItemChoose = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[4]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[4]/uni-view/uni-scroll-view/div/div/div/uni-view[1]"));
        chinaItemChoose.click();
        DriverUtils.wait(1);

        //证照类型
        WebElement choose2 = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[5]/uni-view[2]/uni-view[1]/uni-view"));
        choose2.click();
        DriverUtils.wait(1);

        WebElement item = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[5]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view"));
        item.click();

        //统一社会信用代码
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[6]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getCertificateNumber());

        //法定代表人/负责人
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[7]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getLegalRepresentative());

        //职务
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[8]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getLegalRepresentativeJob());

        //法定代表人证件类型
        choose2 = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[9]/uni-view[2]/uni-view[1]/uni-view"));
        choose2.click();
        DriverUtils.wait(1);

        //选择原告证件
        WebElement pWebElement = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[9]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div"));
        List<WebElement> webElementList = pWebElement.findElements(By.className("fd-item"));
        for(WebElement webElement: webElementList){
            String text = webElement.getText();
            if(text.equals(caseInfo.getLegalRepresentativeCardType())){
               webElement.click();
               break;
            }
        }
       /* item = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[9]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view[1]"));
        item.click();*/

        //法定代表人证件号码
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[10]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.sendKeys(caseInfo.getLegalRepresentativeIDCard());

        //法定代表人手机号码
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[11]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getLegalRepresentativePhone());

        DriverUtils.wait(1);

        button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[2]/uni-button[2]"));
        button.click();
        DriverUtils.wait(3);

        //新增
        button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view/uni-view[2]"));
        button.click();

        DriverUtils.wait(2);


        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantName());

        //性别
        choose2 = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[3]/uni-view[2]/uni-view[1]/uni-view"));
        choose2.click();
        DriverUtils.wait(1);
        if ("男".equals(caseInfo.getDefendantSex())) {
            item = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[3]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view[1]"));
        } else if ("女".equals(caseInfo.getDefendantSex())) {
            item = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[3]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view[2]"));
        } else {
            item = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[3]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view[3]"));
        }
        item.click();
        DriverUtils.wait(1);

        //证件类型
        choose2 = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[5]/uni-view[2]/uni-view[1]/uni-view"));
        choose2.click();
        DriverUtils.wait(1);
        item = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[5]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view[1]"));
        item.click();
        DriverUtils.wait(1);


        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[6]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantIDCard());
        DriverUtils.wait(1);
        //住所地（户籍所在地）
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[12]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantAddress());
        DriverUtils.wait(1);

        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[13]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantPhone());
        DriverUtils.wait(1);

        button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-view[2]/uni-button[2]"));
        button.click();

        DriverUtils.wait(3);

        //代理人
        button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[4]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]"));
        button.click();
        DriverUtils.wait(3);

        //被代理人
        choose2 = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[1]/uni-view[2]/uni-view[1]/uni-checkbox-group/uni-label/uni-view[2]/uni-text"));
        choose2.click();

        //代理人类型
        choose2 = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[2]/uni-view[2]/uni-view[1]/uni-view"));
        choose2.click();
        DriverUtils.wait(1);

        item = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[2]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view[1]"));
        item.click();

        DriverUtils.wait(1);


        WebElement close;
        try {
            //代理人执业证号
            close = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[6]/uni-view[2]/uni-view[1]/uni-view/uni-text"));
            close.click();
            DriverUtils.wait(1);
        } catch (Exception e) {
            //e.printStackTrace();
        }

        try {
            input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[6]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
            input.clear();
            input.sendKeys(caseInfo.getAgentCardCode());
            DriverUtils.wait(1);
        } catch (Exception e) {
            e.printStackTrace();
        }

        //单位
        close = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[7]/uni-view[2]/uni-view[1]/uni-view/uni-text"));
        close.click();

        DriverUtils.wait(1);
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[7]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getAgentUnit());

        //电话
        close = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[8]/uni-view[2]/uni-view[1]/uni-view/uni-text"));
        close.click();

        DriverUtils.wait(1);
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[8]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getAgentPhone());

        DriverUtils.wait(1);

        button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[2]/uni-button[2]"));
        button.click();

        DriverUtils.wait(3);

        if (!isDefendantCompanyCase) {
            WebElement nextPageBtn = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-button[2]"));
            nextPageBtn.click();
            DriverUtils.wait(3);
            return;
        }

        //处理被告法人
        button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view/uni-view[3]"));
        button.click();
        DriverUtils.wait(1);

        //名称
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantLegalRepresentativeName());
        DriverUtils.wait(1);

        //住所地（主要办事机构所在地）
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[3]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantLegalRepresentativeAddress());
        DriverUtils.wait(1);

        //证件类型
        WebElement select = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[5]/uni-view[2]/uni-view[1]/uni-view"));
        select.click();
        DriverUtils.wait(1);

        item = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[5]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view"));
        item.click();
        DriverUtils.wait(1);

        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[6]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.click();
        input.sendKeys(caseInfo.getDefendantCertificateNumber());
        DriverUtils.wait(1);


        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[11]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.click();
        input.sendKeys(caseInfo.getDefendantLegalRepresentativePhone());
        DriverUtils.wait(1);

        WebElement saveButton = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-button[2]"));
        saveButton.click();
        DriverUtils.wait(2);

        WebElement nextPage = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-button[2]"));
        nextPage.click();
        DriverUtils.wait(3);

    }

    public void hasAiContentHandle(CaseInfo caseInfo, boolean isDefendantCompanyCase) {
        try{
            //删除AI填写的数据
            List<WebElement> webElementList = DriverManger.driver.findElements(By.className("uniui-trash"));
            while (webElementList != null && webElementList.size() > 0){
                try{
                    WebElement webElement = webElementList.get(0);
                    webElement.click();
                    DriverUtils.wait(1);
                    WebElement delete = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-modal/div[2]/div[3]/div[2]"));
                    delete.click();
                    DriverUtils.wait(1);
                }catch (Exception e){
                    e.printStackTrace();
                }
                webElementList = DriverManger.driver.findElements(By.className("uniui-trash"));
            }
        }catch (Exception e){

        }

        //添加法人
        WebElement button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[1]/uni-view[3]/uni-view/uni-view[3]"));
        button.click();
        DriverUtils.wait(2);

        //名称
        WebElement input = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getUnitName());

        //住所地（主要办事机构所在地）
        input = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[3]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getPlaintiffAddress());
        DriverUtils.wait(1);

        //国别或地区
        WebElement countryChoose = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[4]/uni-view[2]/uni-view[1]/uni-view"));
        countryChoose.click();
        DriverUtils.wait(1);

        WebElement chinaItemChoose = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[4]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[4]/uni-view/uni-scroll-view/div/div/div/uni-view[1]"));
        chinaItemChoose.click();
        DriverUtils.wait(1);

        //证照类型
        WebElement choose2 = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[5]/uni-view[2]/uni-view[1]/uni-view"));
        choose2.click();
        DriverUtils.wait(1);

        WebElement item = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[5]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view"));
        item.click();

        //统一社会信用代码
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[6]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getCertificateNumber());

        //法定代表人/负责人
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[7]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getLegalRepresentative());

        //职务
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[8]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getLegalRepresentativeJob());

        //法定代表人证件类型
        choose2 = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[9]/uni-view[2]/uni-view[1]/uni-view"));
        choose2.click();
        DriverUtils.wait(1);

        /*item = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[9]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view[1]"));
        item.click();*/


        WebElement pWebElement = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[9]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div"));
        List<WebElement> webElementList = pWebElement.findElements(By.className("fd-item"));
        for(WebElement webElement: webElementList){
            String text = webElement.getText();
            if(text.equals(caseInfo.getLegalRepresentativeCardType())){
                webElement.click();
                break;
            }
        }

        //法定代表人证件号码
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[10]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getLegalRepresentativeIDCard());

        //法定代表人手机号码
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[11]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getLegalRepresentativePhone());

        DriverUtils.wait(1);

        button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[1]/uni-view[2]/uni-view/uni-view[2]/uni-view[2]/uni-button[2]"));
        button.click();
        DriverUtils.wait(5);

        //新增 被告自然人
        button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view/uni-view[2]"));
        button.click();

        DriverUtils.wait(2);


        input = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantName());

        //性别
        choose2 = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[3]/uni-view[2]/uni-view[1]/uni-view/uni-view"));
        choose2.click();
        DriverUtils.wait(1);
        if ("男".equals(caseInfo.getDefendantSex())) {
            item = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[3]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view[1]"));
        } else if ("女".equals(caseInfo.getDefendantSex())) {
            item = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[3]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view[2]"));
        } else {
            item = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[3]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view[3]"));
        }
        item.click();
        DriverUtils.wait(1);

        //证件类型
        choose2 = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[5]/uni-view[2]/uni-view[1]/uni-view"));
        choose2.click();
        DriverUtils.wait(1);
        item = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[5]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view[1]"));
        item.click();
        DriverUtils.wait(1);


        input = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[6]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantIDCard());
        DriverUtils.wait(1);
        //住所地（户籍所在地）
        input = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[12]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantAddress());
        DriverUtils.wait(1);

        input = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[13]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantPhone());
        DriverUtils.wait(1);

        button = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[2]/uni-button[2]"));
        button.click();

        DriverUtils.wait(3);

        //代理人
        button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[4]/uni-view[2]/uni-view/uni-view[1]/uni-view[2]/uni-view"));
        button.click();
        DriverUtils.wait(3);

        //被代理人
        choose2 = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[1]/uni-view[2]/uni-view[1]/uni-checkbox-group/uni-label/uni-view[2]"));
        choose2.click();

        //代理人类型
        choose2 = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[2]/uni-view[2]/uni-view[1]/uni-view"));
        choose2.click();
        DriverUtils.wait(1);

        item = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[2]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view[1]"));
        item.click();

        DriverUtils.wait(1);


        WebElement close;
        try {
            //代理人执业证号
            close = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[6]/uni-view[2]/uni-view[1]/uni-view/uni-text"));
            close.click();

            DriverUtils.wait(1);
            input = DriverManger.driver.findElement(By.xpath("//*[@id=\"add\"]/uni-view[1]/uni-view/uni-form/span/uni-view[6]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
            input.clear();
            input.sendKeys(caseInfo.getAgentCardCode());
        } catch (Exception e) {
            e.printStackTrace();
        }

        //单位
        close = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[7]/uni-view[2]/uni-view[1]/uni-view/uni-text"));
        close.click();

        DriverUtils.wait(1);
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[7]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getAgentUnit());

        //电话
        close = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[8]/uni-view[2]/uni-view[1]/uni-view/uni-text"));
        close.click();

        DriverUtils.wait(1);
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[8]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getAgentPhone());

        DriverUtils.wait(2);

        button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[4]/uni-view[2]/uni-view/uni-view[2]/uni-view[2]/uni-button[2]"));
        button.click();

        DriverUtils.wait(3);

        if(!isDefendantCompanyCase){
            WebElement nextPageBtn = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-button[2]"));
            nextPageBtn.click();
            DriverUtils.wait(3);
            return;
        }
        //新增被告 法人
        button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view/uni-view[3]"));
        button.click();
        DriverUtils.wait(2);

        //法人
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantLegalRepresentativeName());
        DriverUtils.wait(1);

        //住所地
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[3]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantLegalRepresentativeAddress());
        DriverUtils.wait(1);

        //证照类型
        WebElement select = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[5]/uni-view[2]/uni-view[1]/uni-view"));
        select.click();
        DriverUtils.wait(1);

        item = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[5]/uni-view[2]/uni-view[1]/uni-view[3]/uni-view[3]/uni-view/uni-scroll-view/div/div/div/uni-view"));
        item.click();;
        DriverUtils.wait(1);

        //统一社会信用代码
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[6]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantCertificateNumber());
        DriverUtils.wait(1);

        //电话号码
        input = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[1]/uni-view/uni-form/span/uni-view[11]/uni-view[2]/uni-view[1]/uni-view/uni-input/div/input"));
        input.clear();
        input.sendKeys(caseInfo.getDefendantLegalRepresentativePhone());
        DriverUtils.wait(1);

        button = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[1]/uni-view[3]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-view[2]/uni-button[2]"));
        button.click();
        DriverUtils.wait(2);

        WebElement nexPage = DriverManger.driver.findElement(By.xpath("/html/body/uni-app/uni-layout/uni-content/uni-main/uni-page/uni-page-wrapper/uni-page-body/uni-view/uni-view[2]/uni-view[2]/uni-view/uni-view[2]/uni-button[2]"));
        nexPage.click();
        DriverUtils.wait(3);
    }

    public static void main(String[] args) {
      /*  List<String> list = new ArrayList<>();
        list.add("D:\\workSpace\\AutomaticCase\\caseFiling\\1756260035572");
        AutoCaseThread autoCaseThread = new AutoCaseThread(list);
        autoCaseThread.start();*/
    }
}
